﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace HardwareLibrary.PLCLibrary
{
    public class PLCHelper:ComLibrary.ComHelper
    {
        public bool OpenPLCCom(PLC_Struct plc)
        {
            bool flag = false;
            flag = base.OpenComPortNoEvent(plc.iPort, plc.strComParam);
            return flag;
        }
        public bool ClosePlcCom()
        {
            bool flag = false;
            flag = base.CloseComPort();
            return flag;
        }
        public void SendOpenBarCommand(PLC_Struct ps)
        {
            if (OpenPLCCom(ps) == true)
            {
                base.SendData(ps.OpenBarCMD);
                Thread.Sleep(500);
                base.SendData(ps.OpenBarCMD);
                Thread.Sleep(500);
                base.SendData(ps.StopSendCMD);
                Thread.Sleep(100);
                base.SendData(ps.StopSendCMD);
                ClosePlcCom();
            }
        }
    }
}
